package spring1.printer;

public class TextPaper {
	private int linewords;// 一行几个字
	private int linesPage;// 一页几行

	public void setLinewords(int linewords) {
		this.linewords = linewords;
	}

	public int getLinewords() {
		return linewords;
	}

	public int getLinesPage() {
		return linesPage;
	}

	public void setLinesPage(int linesPage) {
		this.linesPage = linesPage;
	}

	public void print(char s) {
		System.out.print(s);
	}

	public void print(String s) {
		char cr[] = s.toCharArray();
		int l = 0, p = 0;
		int page = 1;
		for (int i = 0; i < cr.length; i++) {
			System.out.print(cr[i]);
			l++;
			if (l >= this.linewords) {
				System.out.println();
				l = 0;
				p++;
				if (p >= this.linesPage) {
					System.out.println("\t--" + page + "--");
					page++;
					p = 0;
				}
			}
		}
		if (l != 0 | p != 0) {// 页号
			System.out.println("\t--" + page + "--");
		}
	}
}
